package com.shuziren.question.entity.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.shuziren.question.entity.*;
import jakarta.validation.constraints.Max;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;

import lombok.Data;

import java.util.Date;
import java.util.List;

@JsonIgnoreProperties(ignoreUnknown = true)
@Data
public class InterviewQuestionSetDTO {
    private Integer id;
    // 题目集名称
    @NotNull(message = "名称不能为空")
    private String name;
    // 状态只有0和1，0表示禁用，1表示启用
    @Min(value = 0, message = "状态必须为0")
    @Max(value = 1, message = "状态必须为1")
    private Integer status;
    // 创建时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createdAt;
    // 更新时间
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updatedAt;
    // 题目集职位
    private Integer position;
    // 题目数量
    private Integer questionCount;
    // 难度
    @Size(min = 1,max = 3, message = "难度长度必须在1-3之间")
    private Integer difficulty;
    // 总分
    @Min(value = 5, message = "分值最小为5")
    @Max(value = 100, message = "最大不超过100")
    private Integer score;
    // 题目集分类
    private String Category;


    // 分页
    @NotNull(message = "页码不能为空")
    @Min(value = 1, message = "页码最小为1")
    private Integer pageNum;
    // 每页显示数量
    @NotNull(message = "每页显示数量不能为空")
    @Min(value = -1, message = "每页显示数量最小为1")
    private Integer pageSize;


    // 关联题目
    private List<Integer> questions;


    public InterviewQuestionSet toInterviewQuestionSet() {
        InterviewQuestionSet interviewQuestionSetDTO = new InterviewQuestionSet();
        interviewQuestionSetDTO.setId(this.getId());
        interviewQuestionSetDTO.setName(this.getName());
        interviewQuestionSetDTO.setStatus(this.getStatus());
        interviewQuestionSetDTO.setCreatedAt(this.getCreatedAt());
        interviewQuestionSetDTO.setUpdatedAt(this.getUpdatedAt());
        interviewQuestionSetDTO.setPosition(this.getPosition());
        interviewQuestionSetDTO.setQuestionCount(this.getQuestionCount());
        interviewQuestionSetDTO.setDifficulty(this.getDifficulty());
        interviewQuestionSetDTO.setScore(this.getScore());
        return interviewQuestionSetDTO;
    }
}
